package com.xjtu.controller.admin;

import com.xjtu.dto.assessment.AssessmentDto;
import com.xjtu.dto.registration.CapabilityAssessmentDto;
import com.xjtu.dto.registration.RegistrationDto;
import com.xjtu.result.PageResult;
import com.xjtu.result.Result;
import com.xjtu.service.RegistrationService;
import com.xjtu.vo.ElderlyVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/admin/into")
@Slf4j
@Api(tags = "入住登记接口")
public class RegistrationController {
    @Autowired
    RegistrationService registrationService;
    @PostMapping("register")
    public Result addRegister(@RequestBody @Valid RegistrationDto registrationDto){
        Result result = registrationService.insertNew(registrationDto);
        return result;
    }

    @PostMapping("judge")
    public Result addAssessment(@RequestBody @Valid CapabilityAssessmentDto capabilityAssessmentDto) {
        Result result = registrationService.insertAssessment(capabilityAssessmentDto);
        return result;
    }

    @GetMapping("elderly")
    public Result<PageResult> getElderlyList(@RequestParam(required = false, defaultValue = "1") int page,
                                             @RequestParam(required = false, defaultValue = "10") int perPage,
                                             @RequestParam(required = false, defaultValue = "null") String elderlyName){
        PageResult pageResult = registrationService.getList(page, perPage, elderlyName);
        return Result.success(pageResult);
    }






}
